import 'dart:io';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:leader_help/value/topcolors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:leader_help/utils/util.dart';
import 'logic.dart';

class SetupPage extends StatelessWidget {
  final logic = Get.put(SetupLogic());
  final state = Get.find<SetupLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffF0F2F5),
      appBar: AppBar(leading: BackButton(color: Colors.black,),title: Text('设置',style: TextStyle(color: Colors.black)),elevation: 0,centerTitle: true,backgroundColor: Colors.white,),

      body: GetBuilder<SetupLogic>(
        builder: (logic){
          return CustomScrollView(
            slivers: [
              SliverToBoxAdapter(child: Column(children: [
                GestureDetector(child: Container(child: Row(children: [
                  Expanded(child: Text('设置头像',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp,fontWeight: FontWeight.w500),)),
                  Container(
                    child: ClipOval(
                      child: state.imgPath==null?Image.asset(
                        'avatar_default.png'.imgPathMe,fit: BoxFit.cover,
                      ):Image.file(File(state.imgPath!)),
                    ),
                    width: 50.r,height: 50.r,
                    margin: EdgeInsets.only(right: 5),
                    // decoration: BoxDecoration(borderRadius: BorderRadius.all(Radius.circular(180))),
                  ),
                  Icon(CupertinoIcons.chevron_right,size: 17,color: TopColors.black_99,)
                ],),margin: EdgeInsets.fromLTRB(0,8,0,0),padding: EdgeInsets.fromLTRB(25,15,10,15),decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.all(Radius.circular(5))),),onTap: logic.selectImages),


                GestureDetector(child: Container(child: Row(children: [
                  Expanded(child: Text('用户名',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),)),
                  Text('314234234',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),),
                ],),margin: EdgeInsets.fromLTRB(0,0.5,0,0),padding: EdgeInsets.fromLTRB(25,15,20,15),decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.all(Radius.circular(5))),),onTap: null),


                GestureDetector(child: Container(child: Row(children: [
                  Expanded(child: Text('登录密码设置',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),)),
                  Container(child: Text('去设置',style: TextStyle(color: TopColors.black_99,fontSize: 16.sp),), margin: EdgeInsets.only(right: 5)),
                  Icon(CupertinoIcons.chevron_right,size: 17,color: TopColors.black_99,)
                ],),margin: EdgeInsets.fromLTRB(0,0.5,0,0),padding: EdgeInsets.fromLTRB(25,15,10,15),decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.all(Radius.circular(5))),),onTap: null),


                GestureDetector(child: Container(child: Row(children: [
                  Expanded(child: Text('清除缓存',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),)),
                  Container(child: Text(state.cacheSizeStr+'kb',style: TextStyle(color: TopColors.black_99,fontSize: 16.sp),), margin: EdgeInsets.only(right: 5)),
                  Icon(CupertinoIcons.chevron_right,size: 17,color: TopColors.black_99,)
                ],),margin: EdgeInsets.fromLTRB(0,8,0,0),padding: EdgeInsets.fromLTRB(25,15,10,15),decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.all(Radius.circular(5))),),onTap: null),

                GestureDetector(child: Container(child: Row(children: [
                  Expanded(child: Text('关于我们',style: TextStyle(color: TopColors.black_33,fontSize: 16.sp),)),
                  Container(child:  Text('v1.0.0',style: TextStyle(color: TopColors.black_99,fontSize: 16.sp),),margin: EdgeInsets.only(right: 5)),
                  Icon(CupertinoIcons.chevron_right,size: 17,color: TopColors.black_99,)
                ],),margin: EdgeInsets.fromLTRB(0,0.5,0,0),padding: EdgeInsets.fromLTRB(25,15,10,15),decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.all(Radius.circular(5))),),onTap: (){}),
                GestureDetector(child: Container(child: Center(child: Text('退出登录',
                  style: TextStyle(
                      color: Colors.white, fontSize: 18.sp,fontFamily: 'pingfangB'),),),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(35)),
                      color: Color(0xff27AD63)),
                  padding: EdgeInsets.all(15),
                  margin: EdgeInsets.fromLTRB(20,50,20,20),), onTap: () {

                  Get.back(result: true);
                },),
              ],),)
            ],
          );
        },
      ),
    );
  }
}
